package com.xfn.until;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class LoginLimit {
    public static long loginLimitTime(String time , long limitLogin) {
        SimpleDateFormat timeDateLimit = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        long di = 0;
        if (time != null || !time.equals("")) {
            try {
                Date dateX = timeDateLimit.parse(timeDateLimit.format(new Date()));
                Date dateD = timeDateLimit.parse(time);
                di = dateX.getTime() - dateD.getTime();
                di = di / (1000 * 60);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        } else {
            di = limitLogin + 10;
        }
        return di;
    }

    public static long loginLimitTime(String time) {
        SimpleDateFormat timeDateLimit = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
        long di = 0;
        try {
            /*Date dateX = timeDateLimit.parse(timeDateLimit.format(new Date()));*/
            Date dateD = timeDateLimit.parse(time);
            di = dateD.getTime();
            di = di / (1000 * 60 * 60);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return di;
    }
}
